package com.atxiaodei.kabudashejimoshi.单例模式.饿汉式;

/**
 * @ClassName HungrySingleton
 * @Deacription 饿汉式单例模式
 * @Author 卡布达
 * @Date 2021/10/12 12:37
 * @Version 1.0
 **/
public class HungrySingleton {
    private static final HungrySingleton HUNGRY_SINGLETON=new HungrySingleton();

    // 构造函数私有化
    private HungrySingleton(){}

    public static HungrySingleton getInstance(){
        return  HUNGRY_SINGLETON;
    }

    /*******************************************其他写法***********************************************/
//    private static final HungrySingleton HUNGRY_SINGLETON;
//    static {
//        HUNGRY_SINGLETON=new HungrySingleton();
//    }
//    private HungryStaticSingleton(){}
//    public static HungryStaticSingleton getInstance(){
//        return hungrySingleton;
//    }
}
